package computer;

public class Board {
	private CPU cpu;
	private Memory mem;
	private USB[] usbs = new USB[4];

	public boolean plugin(USB u) {
		for (int i = 0; i < usbs.length; i++) {
			if (usbs[i] == null) {
				usbs[i] = u;
				return true;
			}
		}
		return false;
	}

	public void workUSB() {
		for (int i = 0; i < usbs.length; i++) {
			if (usbs[i] != null)
				usbs[i].start();
		}

	}

	public boolean plugin(CPU c) {

		if (cpu == null) {
			cpu = c;
			return true;

		}
		return false;
	}

	public void workCPU() {

		if (cpu != null)
			cpu.process();
	}

	public boolean plugin(Memory m) {

		if (mem == null) {
			mem = m;
			return true;
		}

		return false;
	}

	public void workMemory() {

		if (mem != null)
			mem.cunchu();
	}
}
